package com.forum.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.forum.model.entity.PostTag;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PostTagMapper extends BaseMapper<PostTag> {
    @Insert("INSERT INTO post_tag (post_id, tag_id, created_at) VALUES (#{postId}, #{tagId}, #{createdAt})")
    int insert(PostTag postTag);

    @Select("SELECT tag_id FROM post_tag WHERE post_id = #{postId}")
    List<Long> selectTagIdsByPostId(Long postId);

    @Select("SELECT post_id FROM post_tag WHERE tag_id = #{tagId}")
    List<Long> selectPostIdsByTagId(Long tagId);

    @Delete("DELETE FROM post_tag WHERE post_id = #{postId}")
    int deleteByPostId(Long postId);
} 